<%--
  Created by IntelliJ IDEA.
  User: 王文尧
  Date: 2024/7/12
  Time: 7:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
  <div style="width: 1000px;margin: auto">
    学号: <input type="text" id="sno"/>
    姓名: <input type="text" id="sname"/>
    性别: <select id="sex">
      <option>不限</option>
      <option>男</option>
      <option>女</option>
    </select>
    年龄: <input id="age"/>
    <button onclick="query()">查询</button>
  </div>
  <table border="1" align="center" width="1000px">
    <tr>
      <th>学号</th>
      <th>姓名</th>
      <th>密码</th>
      <th>性别</th>
      <th>年龄</th>
    </tr>
    <c:forEach items="${pageInfo.data}" var="stu">
      <tr>
        <td>${stu.SNo}</td>
        <td>${stu.SName}</td>
        <td>${stu.password}</td>
        <td>${stu.sex}</td>
        <td>${stu.age}</td>
      </tr>
    </c:forEach>
  </table>
  <div style="width: 1000px;margin: auto">
    当前页${pageInfo.pageIndex}<br/>
    一页几条${pageInfo.pageSize}<br/>
    一共几页${pageInfo.totalPageNum}<br/>
    一共几条${pageInfo.totalDataNum}<br/>
    <a href="manage?op=queryAllStudentsByPage&pageIndex=1&pageSize=${pageInfo.pageSize}">首页</a>
    <c:choose>
      <c:when test="${pageInfo.pageIndex > 1}">
        <a href="manage?op=queryAllStudentsByPage&pageIndex=${pageInfo.pageIndex-1}&pageSize=${pageInfo.pageSize}">上一页</a>
      </c:when>
      <c:otherwise>
        上一页
      </c:otherwise>
    </c:choose>
    <c:forEach var="i" begin="1" end="${pageInfo.totalPageNum}">
      <c:choose>
        <c:when test="${i!=pageInfo.pageIndex}">
          <a href="manage?op=queryAllStudentsByPage&pageIndex=${i}&pageSize=${pageInfo.pageSize}">${i}</a>
        </c:when>
        <c:otherwise>
          ${i}
        </c:otherwise>
      </c:choose>
    </c:forEach>
    <c:choose>
      <c:when test="${pageInfo.pageIndex < pageInfo.totalPageNum}">
        <a href="manage?op=queryAllStudentsByPage&pageIndex=${pageInfo.pageIndex+1}&pageSize=${pageInfo.pageSize}">下一页</a>
      </c:when>
      <c:otherwise>
        下一页
      </c:otherwise>
    </c:choose>
    <a href="manage?op=queryAllStudentsByPage&pageIndex=${pageInfo.totalPageNum}&pageSize=${pageInfo.pageSize}">尾页</a>

    跳转到<input type="number" value="${pageInfo.pageIndex}" id="jumpIndex"/>页<button onclick="jumpPageTo()">跳转</button>
    一页<select onchange="changePageSize(this)">
      <option ${pageInfo.pageSize == 5 ? "selected" : ""}>5</option>
      <option ${pageInfo.pageSize == 10 ? "selected" : ""}>10</option>
      <option ${pageInfo.pageSize == 20 ? "selected" : ""}>20</option>
    </select>条
    总条数 ${pageInfo.totalDataNum}
  </div>
<script type="text/javascript">
  function jumpPageTo() {
    var jumpIndex = document.getElementById("jumpIndex").value; // todo:后面再做校验
    location.href="manage?op=queryAllStudentsByPage&pageIndex=" + jumpIndex + "&pageSize=${pageInfo.pageSize}";
  }
  function changePageSize(obj){
    location.href="manage?op=queryAllStudentsByPage&pageIndex=1&pageSize=" + obj.value;
  }
  function query(){
    debugger
    var sNo = document.getElementById("sno").value;
    var sName = document.getElementById("sname").value;
    var sex = document.getElementById("sex").value;
    var age = document.getElementById("age").value;

    location.href="manage?op=queryAllStudentsByPage&sNo=" + sNo + "&sName=" + sName + "&sex=" + sex + "&age=" + age;
  }
</script>
</body>
</html>
